
Import('check_env all_tests')

env = check_env.Clone()

# Include paths
env.Append(CPPPATH = Split('''
                              #/galerautils/src
                              #/gcache/src
                              #/gcs/src
                           '''))

# For C-style logging
env.Append(CPPFLAGS = ' -DGALERA_LOG_H_ENABLE_CXX -Wno-variadic-macros')
# Disable old style cast warns until code is fixed
env.Append(CPPFLAGS = ' -Wno-old-style-cast')
# Allow zero sized arrays
env.Replace(CCFLAGS = env['CCFLAGS'].replace('-pedantic', ''))
env.Append(CPPFLAGS = ' -Wno-missing-field-initializers')
env.Append(CPPFLAGS = ' -Wno-effc++')

if all_tests:
    env.Append(CPPFLAGS = ' -DGCS_ALLOW_GH74')

gcs_tests_sources = Split('''
                             gcs_tests.cpp
                             gcs_test_utils.cpp
                             gcs_fifo_test.cpp
                             ../gcs_fifo_lite.cpp
                             gcs_sm_test.cpp
                             ../gcs_sm.cpp
                             gcs_comp_test.cpp
                             ../gcs_comp_msg.cpp
                             gcs_state_msg_test.cpp
                             ../gcs_state_msg.cpp
                             gcs_backend_test.cpp
                             ../gcs_backend.cpp
                             gcs_proto_test.cpp
                             ../gcs_act_proto.cpp
                             gcs_defrag_test.cpp
                             ../gcs_defrag.cpp
                             gcs_node_test.cpp
                             ../gcs_node.cpp
                             gcs_group_test.cpp
                             gcs_memb_test.cpp
                             ../gcs_group.cpp
                             gcs_core_test.cpp
                             ../gcs_core.cpp
                             ../gcs_dummy.cpp
                             ../gcs_msg_type.cpp
                             ../gcs.cpp
                             ../gcs_params.cpp
                             gcs_fc_test.cpp
                             ../gcs_fc.cpp
                          ''')



#env.Append(CPPFLAGS = ' -DGCS_USE_GCOMM -DGCS_CORE_TESTING -DGCS_DUMMY_TESTING')
env.Append(CPPFLAGS = ' -DGCS_CORE_TESTING -DGCS_DUMMY_TESTING')

env.Append(LIBS = File('#/gcache/src/libgcache.a'))
env.Append(LIBS = File('#/gcomm/src/libgcomm.a'))
env.Append(LIBS = File('#/galerautils/src/libgalerautils++.a'))
env.Append(LIBS = File('#/galerautils/src/libgalerautils.a'))
env.Append(LIBS = ['m', 'ssl', 'crypto'])

gcs_tests = env.Program(target    = 'gcs_tests',
                        source    = gcs_tests_sources,
                        OBJPREFIX = 'gcs-tests-',
                        LINK      = env['CXX'])

env.Test("gcs_tests.passed", gcs_tests)
env.Alias("test", "gcs_tests.passed")

Clean(gcs_tests, '#/gcs_tests.log')
